package com.doit.mr.day01;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;

/**
 * @DATE 2021/12/7/19:19
 * @Author MDK
 * @Version 2021.2.2
 *      从HDFS上下载文件,由于Windows和hdfs兼容性不好,要在Windows中配置hdfs环境
 **/
public class C02_Demo02 {
    public static void main(String[] args) throws Exception {
        URI uri = new URI("hdfs://linux01:8020");
        Configuration conf = new Configuration();
        String userName = "root";

        FileSystem fs = FileSystem.newInstance(uri, conf, userName);
        //下载的同时修改文件名  默认有crc校验文件,true表示不生成crc文件
        Path src = new Path("/1.txt");
        Path dest = new Path("d://aa.txt");
        fs.copyToLocalFile(false,src,dest,true);
    }
}
